package top.yongyan0624.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yongyan0624.mapper.ClazzMapper;
import top.yongyan0624.pojo.Clazz;
import top.yongyan0624.pojo.Student;
import top.yongyan0624.service.ClazzService;

import java.util.List;

/**
 * @author Yongyan
 * @description: TODO
 * @date 2020/12/24
 **/

@Service
public class ClazzServiceImpl implements ClazzService{

    @Autowired
    private ClazzMapper clazzMapper;

    public void setClazzMapper(ClazzMapper clazzMapper) {
        this.clazzMapper = clazzMapper;
    }

    public Integer addClazz(Clazz clazz) {
        return clazzMapper.addClazz(clazz);
    }

    public Integer deleteClazz(Integer id) {
        return clazzMapper.deleteClazz(id);
    }

    public Integer updateClazz(Clazz clazz) {
        return clazzMapper.updateClazz(clazz);
    }

    public List<Clazz> findAllClazz() {
        return clazzMapper.findAllClazz();
    }

    public PageInfo<Clazz> findAllClazz(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Clazz> clazzList = clazzMapper.findAllClazz();

        return new PageInfo<Clazz>(clazzList);
    }

    public Clazz findById(Integer id) {
        return clazzMapper.findById(id);
    }

    public List<Clazz> findByName(String name) {
        return clazzMapper.findByName(name);
    }

    public List<Clazz> findClazz(Clazz clazz) {
        return clazzMapper.findClazz(clazz);
    }

    public Integer totalClazz() {
        return clazzMapper.totalClazz();
    }
}
